package com.itheima.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author zy9524
 * @company SocialistSuccessor
 * @date 2019/6/14 22:03
 */
@Controller
public class UserController {

    @Autowired
    private UserService userService;

//    @RequestMapping("/findUserById/{id}")
//    public String  findUserById(@PathVariable("id") int id, Model model) {
//        User user = userService.findUserById(id);
//        model.addAttribute("user",user);
//        return "success";
//    }

    @RequestMapping("/findUserById/{id}")
    @ResponseBody
    public User  findUserById(@PathVariable("id") int id) {
        return userService.findUserById(id);
    }

}
